import 'package:flutter/material.dart';

import 'package:get/get.dart';
import 'package:getwidget/colors/gf_color.dart';
import 'package:getwidget/components/avatar/gf_avatar.dart';
import 'package:getwidget/components/button/gf_button.dart';
import 'package:getwidget/components/button/gf_button_bar.dart';
import 'package:getwidget/components/card/gf_card.dart';
import 'package:getwidget/components/list_tile/gf_list_tile.dart';
import 'package:getwidget/position/gf_position.dart';
import 'package:getwidget/types/gf_button_type.dart';

import '../controllers/gfcard_controller.dart';

class GfcardView extends GetView<GfcardController> {
  String avatarUrl = 'https://i0.hdslb.com/bfs/face/d857929b564a8aa7c63ac40b32f952841928e2d9.jpg@128w_128h_1o.webp';
  String avatarPath = 'assets/images/bg_drawer.jpg';
  String userPath = 'assets/images/cliu.jpg';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('卡片'),
        centerTitle: true,
      ),
      body: Container(
        child: ListView(
          children: [
            GFCard(
              boxFit: BoxFit.contain,
              titlePosition: GFPosition.end,
              showImage: true,
              image: Image.asset(
                avatarPath,
                height: MediaQuery.of(context).size.height * 0.2,
                width: MediaQuery.of(context).size.width,
                fit: BoxFit.cover,
              ),

              elevation: 10,
              title: GFListTile(
                avatar: GFAvatar(
                  backgroundImage: NetworkImage(avatarUrl),
                ),
                title: Text('初六'),
                subTitle: Text('懂二进制的男人'),
              ),
              content: Text("https://space.bilibili.com/1601108355"),
              buttonBar: GFButtonBar(
                children: <Widget>[
                  GFButton(
                    onPressed: () {},
                    text: 'Buy',
                  ),
                  GFButton(
                    onPressed: () {},
                    text: 'Cancel',
                    type: GFButtonType.outline2x
                  ),
                ],
              ),
            ),

            GFCard(
              boxFit: BoxFit.cover,
              titlePosition: GFPosition.start,
              elevation: 10,
              image: Image.asset(
                avatarPath,
                height: MediaQuery.of(context).size.height * 0.2,
                width: MediaQuery.of(context).size.width,
                fit: BoxFit.cover,
              ),
              showImage: true,
              title: GFListTile(
                avatar: GFAvatar(
                  backgroundImage: AssetImage(userPath),
                ),
                titleText: '初六',
                subTitleText: '懂二进制的男人',
              ),
              content: Text("https://space.bilibili.com/1601108355"),
              buttonBar: GFButtonBar(
                children: <Widget>[
                  GFAvatar(
                    backgroundColor: GFColors.PRIMARY,
                    child: Icon(
                      Icons.share,
                      color: Colors.white,
                    ),
                  ),
                  GFAvatar(
                    backgroundColor: GFColors.SECONDARY,
                    child: Icon(
                      Icons.search,
                      color: Colors.white,
                    ),
                  ),
                  GFAvatar(
                    backgroundColor: GFColors.SUCCESS,
                    child: Icon(
                      Icons.phone,
                      color: Colors.white,
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
